[HVM] Save/restore cleanups 04: Move new domctls out of common code.
authorTim Deegan <Tim.Deegan@xensource.com>
Sat, 20 Jan 2007 11:17:41 +0000 (11:17 +0000)
committerTim Deegan <Tim.Deegan@xensource.com>
Sat, 20 Jan 2007 11:17:41 +0000 (11:17 +0000)
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
xen/arch/x86/domctl.c
xen/common/domain.c
xen/common/domctl.c

index fdc102c1a54b61d7e395aa0d4dfb3fb9013962ce..26babd34e795487d9a807f07297d06867bc0f2d8 100644 (file)
@@ -293,6 +293,80 @@ _long arch_do_domctl(
     }
     break;
 
+    case XEN_DOMCTL_sethvmcontext:
+    { 
+        struct hvm_domain_context *c;
+        struct domain             *d;
+        struct vcpu               *v;
+
+        ret = -ESRCH;
+        if ( (d = find_domain_by_id(domctl->domain)) == NULL )
+            break;
+
+        ret = -ENOMEM;
+        if ( (c = xmalloc(struct hvm_domain_context)) == NULL )
+            goto sethvmcontext_out;
+
+        v = d->vcpu[0];
+        
+        ret = -EFAULT;
+
+#ifndef CONFIG_COMPAT
+        if ( copy_from_guest(c, domctl->u.hvmcontext.ctxt, 1) != 0 )
+            goto sethvmcontext_out;
+
+        ret = arch_sethvm_ctxt(v, c);
+#endif
+
+        xfree(c);
+
+    sethvmcontext_out:
+        put_domain(d);
+
+    }
+    break;
+
+
+    case XEN_DOMCTL_gethvmcontext:
+    { 
+        struct hvm_domain_context *c;
+        struct domain             *d;
+        struct vcpu               *v;
+
+        ret = -ESRCH;
+        if ( (d = find_domain_by_id(domctl->domain)) == NULL )
+            break;
+
+        ret = -ENOMEM;
+        if ( (c = xmalloc(struct hvm_domain_context)) == NULL )
+            goto gethvmcontext_out;
+
+        v = d->vcpu[0];
+
+        ret = -ENODATA;
+        if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) )
+            goto gethvmcontext_out;
+        
+        ret = 0;
+        if (arch_gethvm_ctxt(v, c) == -1)
+            ret = -EFAULT;
+
+#ifndef CONFIG_COMPAT
+        if ( copy_to_guest(domctl->u.hvmcontext.ctxt, c, 1) )
+            ret = -EFAULT;
+
+        xfree(c);
+#endif
+
+        if ( copy_to_guest(u_domctl, domctl, 1) )
+            ret = -EFAULT;
+
+    gethvmcontext_out:
+        put_domain(d);
+
+    }
+    break;
+
     default:
         ret = -ENOSYS;
         break;
index aa232585c8a24b467dd092d25e556cc7b2605423..28530c40d5bb3c2cb0fbd2a9bd6423e4175aebca 100644 (file)
@@ -24,7 +24,6 @@
 #include <xen/percpu.h>
 #include <xen/multicall.h>
 #include <asm/debugger.h>
-#include <asm/hvm/support.h>
 #include <public/sched.h>
 #include <public/vcpu.h>
 #ifdef CONFIG_COMPAT
index a374b1ca326a171e3f1fcded391815e102fc8668..3c0e1cd7bc71d3dfce7018ba36507eac8f71cbbb 100644 (file)
@@ -218,39 +218,6 @@ ret_t do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
     }
     break;
 
-    case XEN_DOMCTL_sethvmcontext:
-    { 
-        struct hvm_domain_context *c;
-        struct domain             *d;
-        struct vcpu               *v;
-
-        ret = -ESRCH;
-        if ( (d = find_domain_by_id(op->domain)) == NULL )
-            break;
-
-        ret = -ENOMEM;
-        if ( (c = xmalloc(struct hvm_domain_context)) == NULL )
-            goto sethvmcontext_out;
-
-        v = d->vcpu[0];
-        
-        ret = -EFAULT;
-
-#ifndef CONFIG_COMPAT
-        if ( copy_from_guest(c, op->u.hvmcontext.ctxt, 1) != 0 )
-            goto sethvmcontext_out;
-
-        ret = arch_sethvm_ctxt(v, c);
-#endif
-
-        xfree(c);
-
-    sethvmcontext_out:
-        put_domain(d);
-
-    }
-    break;
-
     case XEN_DOMCTL_pausedomain:
     {
         struct domain *d = find_domain_by_id(op->domain);
@@ -605,46 +572,6 @@ ret_t do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl)
     }
     break;
 
-    case XEN_DOMCTL_gethvmcontext:
-    { 
-        struct hvm_domain_context *c;
-        struct domain             *d;
-        struct vcpu               *v;
-
-        ret = -ESRCH;
-        if ( (d = find_domain_by_id(op->domain)) == NULL )
-            break;
-
-        ret = -ENOMEM;
-        if ( (c = xmalloc(struct hvm_domain_context)) == NULL )
-            goto gethvmcontext_out;
-
-        v = d->vcpu[0];
-
-        ret = -ENODATA;
-        if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) )
-            goto gethvmcontext_out;
-        
-        ret = 0;
-        if (arch_gethvm_ctxt(v, c) == -1)
-            ret = -EFAULT;
-
-#ifndef CONFIG_COMPAT
-        if ( copy_to_guest(op->u.hvmcontext.ctxt, c, 1) )
-            ret = -EFAULT;
-
-        xfree(c);
-#endif
-
-        if ( copy_to_guest(u_domctl, op, 1) )
-            ret = -EFAULT;
-
-    gethvmcontext_out:
-        put_domain(d);
-
-    }
-    break;
-
     case XEN_DOMCTL_getvcpuinfo:
     { 
         struct domain *d;